#!/bin/bash

BINDIR=$(cd $(dirname $0) && pwd)

. ${BINDIR}/common
. ${BINDIR}/functions

export MEDIADIR FPPDIR CFGDIR CFGFILE SETTINGSFILE LOGDIR
EXT=$(basename $1 | sed -e "s/.*\.\([^\.]*\)/\1/")

if [ "x${EXT}" = "xsh" ]
then
	exec /bin/bash "$@"
elif [ "x${EXT}" = "xpl" ]
then
	exec /usr/bin/perl "$@"
elif [ "x${EXT}" = "xphp" ]
then
	exec /usr/bin/php "$@"
elif [ "x${EXT}" = "xpy" ]
then
	exec /usr/bin/python "$@"
elif [ -x $1 ]
then
	EXECUTABLE=$1
	shift
	exec $EXECUTABLE "$@"
else
	
	echo "ERROR: Unknown file extension: ${EXT} on $1"
fi
